Mapping of Sequence Reads to the Reference Genomes ◾ 79
and a tab-delimited file with an extension “*SJ.out.tab”. The “*Log.out” file contains
detailed information about the run. The “*Log.progres.out” file contains statistics for the
alignment progress in 1-minute intervals. The “*Log.final.out” file contains important
summary statistics for the alignment after the alignment is complete. We will discuss
this later in the RNA-Seq chapter. “*Log.final.out” contains information about the splice
junctions.
2.4 MANIPULATING ALIGNMENTS IN SAM/BAM FILES
Before proceeding to the next step of the analysis workflow, we may need to manipulate the
alignments in the SAM/BAM file. There are several programs used to serve that purpose
but Samtools and PICARD are the most commonly used ones. In the following, we will
discuss how to use Samtools to manipulate alignments in SAM/BAM files. PICARD will
be discussed in the RNA-Seq chapter.
2.4.1 Samtools
Samtools is a collection of command-line utilities for the manipulation of alignments in
the SAM/BAM files. These utilities are grouped into indexing, editing, file operations, sta-
tistics, and viewing tools. Samtools can be installed on Linux by running “sudo apt-get
install samtools” or you can follow the installation instructions available at “http://www.
htslib.org/download/”. After installation, you can display the complete list of the Samtools’
utilities by running “samtools” without any option on the command line.
A Samtools utility is executed using the following format:
samtools <command> [options]
where <command> is any Samtools command and [options] is any of the command
options.
The most used commands include “cat”, “index”, “markup”, “rmdup”, “sort”, “mpileup”,
“coverage”, “depth”, “flagstats”, and “view”.
To learn more about the usage and options of any of these commands, you can use the
following format:
samtools <command>
For instance, to display the usage and options of “index” command, run “samtools index”.
In the following, we will discuss the most common uses of Samtools utilities.
2.4.1.1 SAM/BAM Format Conversion
The “samtools view” command can be used to convert SAM file into BAM file and vice
versa. If you did not delete the SAM files, which were produced above and saved in “sam”
directory, you can use any one of them for this practice.
From inside “sam” directory, for instance, you can run the following command to con-
vert “SRR769545_mem.sam” to a BAM file “SRR769545_mem.bam”: